package com.hsnn.medstgmini.trading.pur.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.hsnn.medstgmini.model.Status;
import com.hsnn.medstgmini.sys.model.SysUser;

/**
 * @category 送货地址
 * @author 蔡春龙
 * @date 2015年7月8日
 */
@Entity
@Table(name = "pur_hospaddress")
public class HospAddress {

	@Id
	@Column(name = "recp_addr_id")
	private String recpAddrId; // 送货地址id

	@Column(name = "hosp_id")
	private String hospId; // 医疗机构id

	@OneToOne
	@NotFound(action = NotFoundAction.IGNORE)
	@JoinColumn(name = "user_id", referencedColumnName = "id")
	private SysUser user; // 采购用户id

	@Column(name = "recp_addr_s")
	private String recpAddrS; //

	@Column(name = "recp_addr")
	private String recpAddr; // 送货地址

	@Column(name = "recp_user")
	private String recpUser; // 收货人

	@Column(name = "recp_userphone")
	private String recpUserphone; // 收货人电话

	@Column(name = "status")
	private Integer status; // 状态

	@Transient
	private String statusName; // 状态名称

	@Column(name = "isdefault")
	private Integer isdefault; // 是否默认

	@Column(name = "upd_datetime")
	private Date updDateTime; // 更新时间

	@Column(name = "upd_user")
	private String updUser; // 更新人

	@Transient
	private String userIds; // 选中的用户id集合(分号分隔)

	public String getRecpAddrId() {
		return recpAddrId;
	}

	public void setRecpAddrId(String recpAddrId) {
		this.recpAddrId = recpAddrId;
	}

	public String getHospId() {
		return hospId;
	}

	public void setHospId(String hospId) {
		this.hospId = hospId;
	}

	public SysUser getUser() {
		return user;
	}

	public void setUser(SysUser user) {
		this.user = user;
	}

	public String getRecpAddrS() {
		return recpAddrS;
	}

	public void setRecpAddrS(String recpAddrS) {
		this.recpAddrS = recpAddrS;
	}

	public String getRecpAddr() {
		return recpAddr;
	}

	public void setRecpAddr(String recpAddr) {
		this.recpAddr = recpAddr;
	}

	public String getRecpUser() {
		return recpUser;
	}

	public void setRecpUser(String recpUser) {
		this.recpUser = recpUser;
	}

	public String getRecpUserphone() {
		return recpUserphone;
	}

	public void setRecpUserphone(String recpUserphone) {
		this.recpUserphone = recpUserphone;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getStatusName() {
		if (status != null) {
			statusName = Status.getName(status);
		}
		return statusName;
	}

	public void setStatusName(String statusName) {
		this.statusName = statusName;
	}

	public Integer getIsdefault() {
		return isdefault;
	}

	public void setIsdefault(Integer isdefault) {
		this.isdefault = isdefault;
	}

	public Date getUpdDateTime() {
		return updDateTime;
	}

	public void setUpdDateTime(Date updDateTime) {
		this.updDateTime = updDateTime;
	}

	public String getUpdUser() {
		return updUser;
	}

	public void setUpdUser(String updUser) {
		this.updUser = updUser;
	}

	public String getUserIds() {
		return userIds;
	}

	public void setUserIds(String userIds) {
		this.userIds = userIds;
	}

	@Override
	public String toString() {
		return "HospAddress [recpAddrId=" + recpAddrId + ", hospId=" + hospId
				+ ", user=" + user + ", recpAddrS=" + recpAddrS + ", recpAddr="
				+ recpAddr + ", recpUser=" + recpUser + ", recpUserphone="
				+ recpUserphone + ", status=" + status + ", statusName="
				+ statusName + ", isdefault=" + isdefault + ", updDateTime="
				+ updDateTime + ", updUser=" + updUser + ", userIds=" + userIds
				+ "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((hospId == null) ? 0 : hospId.hashCode());
		result = prime * result
				+ ((isdefault == null) ? 0 : isdefault.hashCode());
		result = prime * result
				+ ((recpAddr == null) ? 0 : recpAddr.hashCode());
		result = prime * result
				+ ((recpAddrId == null) ? 0 : recpAddrId.hashCode());
		result = prime * result
				+ ((recpAddrS == null) ? 0 : recpAddrS.hashCode());
		result = prime * result
				+ ((recpUser == null) ? 0 : recpUser.hashCode());
		result = prime * result
				+ ((recpUserphone == null) ? 0 : recpUserphone.hashCode());
		result = prime * result + ((status == null) ? 0 : status.hashCode());
		result = prime * result
				+ ((statusName == null) ? 0 : statusName.hashCode());
		result = prime * result
				+ ((updDateTime == null) ? 0 : updDateTime.hashCode());
		result = prime * result + ((updUser == null) ? 0 : updUser.hashCode());
		result = prime * result + ((user == null) ? 0 : user.hashCode());
		result = prime * result + ((userIds == null) ? 0 : userIds.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		HospAddress other = (HospAddress) obj;
		if (hospId == null) {
			if (other.hospId != null)
				return false;
		} else if (!hospId.equals(other.hospId))
			return false;
		if (isdefault == null) {
			if (other.isdefault != null)
				return false;
		} else if (!isdefault.equals(other.isdefault))
			return false;
		if (recpAddr == null) {
			if (other.recpAddr != null)
				return false;
		} else if (!recpAddr.equals(other.recpAddr))
			return false;
		if (recpAddrId == null) {
			if (other.recpAddrId != null)
				return false;
		} else if (!recpAddrId.equals(other.recpAddrId))
			return false;
		if (recpAddrS == null) {
			if (other.recpAddrS != null)
				return false;
		} else if (!recpAddrS.equals(other.recpAddrS))
			return false;
		if (recpUser == null) {
			if (other.recpUser != null)
				return false;
		} else if (!recpUser.equals(other.recpUser))
			return false;
		if (recpUserphone == null) {
			if (other.recpUserphone != null)
				return false;
		} else if (!recpUserphone.equals(other.recpUserphone))
			return false;
		if (status == null) {
			if (other.status != null)
				return false;
		} else if (!status.equals(other.status))
			return false;
		if (statusName == null) {
			if (other.statusName != null)
				return false;
		} else if (!statusName.equals(other.statusName))
			return false;
		if (updDateTime == null) {
			if (other.updDateTime != null)
				return false;
		} else if (!updDateTime.equals(other.updDateTime))
			return false;
		if (updUser == null) {
			if (other.updUser != null)
				return false;
		} else if (!updUser.equals(other.updUser))
			return false;
		if (user == null) {
			if (other.user != null)
				return false;
		} else if (!user.equals(other.user))
			return false;
		if (userIds == null) {
			if (other.userIds != null)
				return false;
		} else if (!userIds.equals(other.userIds))
			return false;
		return true;
	}

	
}
